import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { FirmwareWristbandFile } from './firmwareWristbandFile.entity';

@Entity('firmware_wristband')
export class FirmwareWristband {
  @PrimaryGeneratedColumn('increment')
  id: number; // 自增 ID

  @Column({ type: 'varchar', length: 255, default: '' })
  name: string; // 固件名称

  @Column({ type: 'varchar', length: 255, default: '' })
  version: string; // 固件版本号

  @Column({ type: 'boolean', default: false })
  raw: boolean; // 是否为原始版本

  @CreateDateColumn({ type: 'timestamp', nullable: true })
  date: Date; // 发布时间

  @Column({ type: 'text', nullable: true })
  desc: string; // 描述信息

  @Column({ type: 'varchar', length: 255, default: '' })
  path: string; // 固件存储路径

  @Column({ type: 'varchar', length: 255, default: '' })
  firmware: string;

  @Column({ type: 'char', length: 36, nullable: true })
  fileid: string | null; // 文件 ID

  @ManyToOne(() => FirmwareWristbandFile, file => file.fileid, {
    nullable: true,
    onDelete: 'SET NULL',
  })
  @JoinColumn({ name: 'fileid' })
  file: FirmwareWristbandFile | null;

  

  @Column({ type: 'boolean', default: false})
  deleted: boolean;
}
